<?php

/**
 * Contacto form.
 *
 * @package    Sanitas
 * @subpackage form
 * @author     Jose Antonio Sánchez Bedoya
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ContactoForm extends BaseContactoForm
{
  public function configure()
  {
      //Following code will remove Required validators from these fields.
  	unset($this->validatorSchema['created_at']);
  	unset($this->validatorSchema['updated_at']);
        unset($this->validatorSchema['validated_at']);
        unset($this->validatorSchema['is_validated']);
        unset($this->validatorSchema['removed_at']);
        unset($this->validatorSchema['remove_it']);
        unset($this->validatorSchema['users_list']);
        unset($this->validatorSchema['polizas_list']);
        unset($this->validatorSchema['grupos_list']);
        unset($this->validatorSchema['my_users_list']);
        //following code will remove fields from form
  	unset($this->widgetSchema['created_at']);
  	unset($this->widgetSchema['updated_at']);
        unset($this->widgetSchema['validated_at']);
        unset($this->widgetSchema['is_validated']);
        unset($this->widgetSchema['removed_at']);
        unset($this->widgetSchema['remove_it']);
        unset($this->widgetSchema['users_list']);
        unset($this->widgetSchema['polizas_list']);
        unset($this->widgetSchema['grupos_list']);
        unset($this->widgetSchema['my_users_list']);
        
        // Definicion de Widgets
        /* No funciona el rango es de solo 10años */
        /*$this->widgetSchema['fecha_nac'] = new sfWidgetFormJQueryDate(array(
    	       //**'format' => '%date%', 
  	           'culture' => sfContext::getInstance()->getUser()->getCulture(),
                   'image' => '/images/calendar.gif',
  	)); 
  	$this->widgetSchema['fecha_nac']->getOption('date_widget')->setOption('format', '%day%/%month%/%year%');
        */
        
        $min_año = sfconfig::get('app_rango_año_min');
        $max_año = sfconfig::get('app_rango_año_max');
  	$years = range($min_año, $max_año);
        
	$this->widgetSchema['fecha_nac'] = new sfWidgetFormDate(
  	array('years' => array_combine($years, $years),
		  'format' => '%day% - %month% - %year%')
	);
        $idiomas = sfconfig::get('app_idiomas_list');
        array_unshift($idiomas, "");
        $this->setWidget('idioma', new sfWidgetFormChoice(array(
                                            'choices' => $idiomas,
                                      )));
        $this->setWidget('autoriza', new sfWidgetFormChoice(array(
                                            'expanded' => true,                                            
                                            'choices'  => array('no','sí'),
                        )));
        // Validadores
        $this->validatorSchema['fecha_nac'] = new sfValidatorDate(array('required' => false));
        $this->validatorSchema['idioma'] =  new sfValidatorPass(array('required' => false));
        $this->validatorSchema['autoriza'] =  new sfValidatorPass(array('required' => false));
  }
}
